1 创建库c50
create database c50 charset utf8;

2 进入这个库
use c50;

3 删库
drop database c50 ;

4 创建学生表
create table stu(sname char(30),sex tinyint,age tinyint) charset utf8;

5 查看所有表
show tables;

6 查看表结构
desc stu;

7 添加数据
insert into stu set sname='李四',sex=1,age=29;

8 查看表数据(只查部分字段)
select sname,sex from stu;

9 查看所有字段
select * from stu;

10 删除表
drop table stu;

11 enum分析
enum('男','女','保密')

1 	男
2	女
3 	保密

李飞     1
小梅		2

insert into user set sex=男
insert into user set sex=1


12 查找enum字段值为男的信息
 select * from user where sex='男';

13 删除库
drop database c50;

14 创建库
create database c50 charset utf8;

15 进入库
use c50;

16 创建学生表
create table stu(id int primary key auto_increment,
sname char(20),
age tinyint default 0,
sex enum('男','女','保密') default '保密'
)charset utf8;

17 插入数据
insert into stu set sname='李四',age=22,sex=1;
insert into stu set sname='李小光',age=39,sex=1;
insert into stu set sname='小梅',age=28,sex=2;
insert into stu set sname='李明',age=19,sex=1;
insert into stu set sname='王珂',age=36,sex=2;
insert into stu set sname='郭小玉',age=29,sex=2;
insert into stu set sname='宋江',age=26,sex=1;
insert into stu set sname='刘德华',age=20,sex=1;
insert into stu set sname='黎明',age=17,sex=1;
insert into stu set sname='宋佳',age=27,sex=2;

18 查询所有记录
select * from stu;

19 查找年龄大于20岁的
select * from stu where age>20;

20 年龄大于20的女生
select * from stu where age>20 and sex=2;

21 年龄大于20并小于30岁的男生
select * from stu where age>20 and age<30 and sex=1;

22 查找年龄大于20的男生或年龄小于30的女生
select * from stu where age>20 and sex=1 or age<30 and sex=2;


























